﻿using Godot;
using System;

public static class RectUtil
{
    public static Rect2 FromMinMax(float left, float top, float right, float bottom)
    {
        return new Rect2(left, top, right - left, bottom - top);
    }
    public static (float xMin, float xMax, float yMin, float yMax) GetMinMax(this Rect2 r)
    {
        return (r.Position.x, r.Position.y, r.End.x, r.End.y);
    }
    public static Rect2 FromMinMax(Vector2 start, Vector2 end)
    {
        var xMin = Math.Min(start.x, end.x);
        var yMin = Math.Min(start.y, end.y);
        var xMax = Math.Max(start.x, end.x);
        var yMax = Math.Max(start.y, end.y);
        return new Rect2(xMin, yMin, xMax - xMin, yMax - yMin);
    }
}
